/**
 * @Author:高志斐
 * @Date:2020/7/14
 * @Description:这是实名认证结果页
 */
import React,{Component} from "react";
import {WhiteSpace, Icon, NavBar} from 'antd-mobile';
import axios from "axios";
import {URL} from '../../index'
import {getCookieId} from "../Login/Component_Login/GetCookie";

export default class ApproveResult extends Component{
    constructor(props) {
        super(props);
        this.state = {
            name:null,
            phone:null,
            idCard:null,
            address:null
        };
        this.handleLeftClick=this.handleLeftClick.bind(this)
        this.loadApprove=this.loadApprove.bind(this)
    }
    //设置缓存，返回我的页
    handleLeftClick(event){
        localStorage.setItem('tabs',2);
        this.props.history.push('/terran/my')
    }
    loadApprove(){
        axios({
            method:"GET",
            url:URL+"/userInfo/getAuthenticationInfo",
            params:{userId:getCookieId()}
        }).then(res=>{
            if (res.data.code === 200) {
                this.setState({
                    name:res.data.userName,
                    phone:"*******"+res.data.userPhone.substring(res.data.userPhone.length-4),
                    idCard:res.data.userCard.substring(0,1)+"****************"+res.data.userCard.substring(res.data.userCard.length-1),
                    address:res.data.userAddress
                })
            }else{
                console.log(res.data)
            }
        })
    }
    componentDidMount() {
        this.loadApprove()
    }
    render() {
        return (
            <div>
                <NavBar
                    mode="light"
                    icon={<Icon type="left" style={{color:"#f8a83f"}}/>}
                    onLeftClick={this.handleLeftClick}
                >实名认证结果</NavBar>
                <div className='transactionDetail-div' >
                    <span style={{color:'#9f9f9f'}}>姓名</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>{this.state.name}</span>
                </div>
                <div className='transactionDetail-div' style={{backgroundColor:"white"}}>
                    <span style={{color:'#9f9f9f'}}>手机号</span>&nbsp;&nbsp;&nbsp;&nbsp;<span>{this.state.phone}</span>
                </div>
                <div className='transactionDetail-div'>
                    <span style={{color:'#9f9f9f'}}>身份证号</span><span>{this.state.idCard}</span>
                </div>
                <div className='transactionDetail-div' style={{backgroundColor:"white"}}>
                    <span style={{color:'#9f9f9f'}}>地址</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>{this.state.address}</span>
                </div>
            </div>
        )
    }
}
